package com.aabte.java8;


import org.testng.annotations.Test;

import java.util.Optional;

public class OptionalTest {

    @Test
    public void optional1Test() {

        Optional<String> fullName = Optional.ofNullable(null);
        System.out.println("Full Name is set? " + fullName.isPresent());
        System.out.println("Full Name: " + fullName.orElse("[none]"));
        System.out.println(fullName.map(s -> "Hello " + s + "!").orElse("Hello World!"));

        System.out.println();

        Optional<String> firstName = Optional.of("Tom");
        System.out.println("First Name is set? " + firstName.isPresent());
        System.out.println("First Name: " + firstName.orElse("[none]"));
        System.out.println(firstName.map(s -> "Hello " + s + "!").orElse("Hello World!"));

    }

}
